function validateForm(classNameRoot, classNameInput) {
    if ($('.' + classNameRoot)) {
        $('.' + classNameRoot + ' .' + classNameInput).each(function() {
            val = $(this).val();
            if ($(this).val() === "")
                $(this).addClass('ui-err');
            else
                $(this).removeClass('ui-err');
        });
    }
}

var changelanguage_Click=function(lgid)
{
    var str=window.location.toString();
    
    window.location="/changelanguage.html?id="+lgid + "&url=" + str;
    
};

var ChiTietTinNhan_Click=function(idtin)
{
     cmdChiTietTinNhan([{name: 'ID', value: '' + idtin + ''}]);
};

 function number(e) {
    var theEvent = e || window.event;
    var key = theEvent.keyCode || theEvent.which;
    if (key !== 13 && key !== 9 && key !== 8 && key !== 37 && key !== 39 && key !== 46) {//allow enter and tab
        key = String.fromCharCode(key);
        var regex = /[0-9]/;
        if (!regex.test(key)) {
            theEvent.returnValue = false;
            if (theEvent.preventDefault) theEvent.preventDefault();
        }
    }
}

$(document).ready(function () {
    $("input[type=text]").filter(".number").on({
        "focus": function (e) {
            $(e.target).data('oldValue', $(e.target).val());
        },
        "keypress": function (e) {
            e.target.oldvalue = e.target.value;
            number(e);
        },
        "change": function (e) {
            var t = e.target;
            var min = $(t).attr("min");
            var val = parseInt($(t).val(), 10);
            if (val < min || 9999999999 < val) {
                alert("Invalid value!");
                $(t).val($(t).data('oldValue'));
            }
        }
    });
});

 